package utils

import (
	"github.com/golang/protobuf/ptypes/timestamp"
	"google.golang.org/protobuf/types/known/timestamppb"
	"time"
)

// PbPtypesToTime pb(ptypes/timestamp) 转 time
func PbPtypesToTime(pbTime *timestamp.Timestamp) time.Time {
	return time.Unix(pbTime.GetSeconds(), 0)
}

// GoTimeToPbPtypes go time格式转pb(ptypes/timestamp)
func GoTimeToPbPtypes(goTime time.Time) *timestamp.Timestamp {
	return timestamppb.New(goTime)
}
